<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class load_test_ctr extends CI_Controller {


    function __construct()
    {
        parent::__construct();
 
        $this->load->database();
		$this->load->library('grocery_CRUD');    
 
    }
	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		  $this->load->model('load_test_model');
		  $wilayar['wrecords'] = $this->load_test_mdl->get_wilaya($record_id);
	}
	
	public function send_result()
	{
	$record_id = $_POST['record_id']; //set the record ID
    $this->load->model('load_test_mdl');   //load the model file
	$wilayar['wrecords'] = $this->load_test_mdl->get_wilaya($record_id); // call the method get_wilaya inside the class load_test_mdl
    
	//echo in the controller to avoid duplicating the view, this echo will be shown via ajax in the corresponding view	
	if(isset($wilayar['wrecords']) ){foreach ($wilayar['wrecords'] as $row){echo($row->nom_fr);}}	
	}
	
	
	public function employees_example()
    {

	$crud = new grocery_CRUD();

    $crud->set_table('t_test');

	$crud->unset_delete();
	$crud->unset_edit();
	$crud->unset_read();
	 

	 $crud->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png', 'load_test_ctr/action_photos()');

	$crud->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png', 'welcome/index');

	
	 
   // $crud->set_subject('conventions');
 
        $output = $crud->render();
 
     //   $this->load->view('list_fourn_per_article_vew',$output);
		
		$crud3 = new grocery_CRUD();
 
        $crud3->set_table('t_test');
		$crud3->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png', 'welcome/index');
        $output3 = $crud3->render();
        $this->_example_output3($output3); 
                 
    }
	
	
	////
	public function aaa()
    {
        $crud = new grocery_CRUD();
		
		$crud->set_model('my_custom_model');
		$crud->set_table($fournisseur_arrays);

        $output = $crud->render();
 
        $this->_example_output($output);
	                
    }
	////
	
	
	
	public function view_example()
    {
        $crud = new grocery_CRUD();
		
	//	 $crud->set_theme('datatables');
	$crud->set_primary_key('id_article','charticle_v');
    $crud->set_table('charticle_v');
   //load_test_ctr/view_example
	 $crud->unset_delete();
	 $crud->unset_edit();
	 $crud->unset_read();
	 
	// $crud->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png', 'welcome/index');
	
	 
  //  $crud->set_subject('conventions');
   // $crud->set_relation('id_chapitre','chapitres','nom_chapitre');
   // $crud->required_fields('id_convention_fk');
    // $crud->display_as('id_chapitre','nom');
   // $crud->fields('id_article','nom','solde','id_chapitres');
   // $crud->columns('id_article','nom','solde','nom_chapitre');
 

       // $crud->set_table('articles');
        $output = $crud->render();
 
        $this->_example_output($output);
		
		 
		
		
		  $crud3 = new grocery_CRUD();
 
        $crud3->set_table('fournisseurs');
        $output3 = $crud3->render();
        $this->_example_output3($output3); 
 
		
		
		                
    }
	
	
 
    function _example_output($output = NULL)
 
    {
       $this->load->view('list_fourn_per_article_vew',$output);
    }    

 
    function _example_output3($output3 = NULL)
 
    {
        $this->load->view('crude_exemple_vew',$output3);    
    } 
	
	//////////////////////////////
	
	public function action_photos()
    {
        //Just a quick filtering of $_GET 
        $country = preg_replace("/([^a-zA-Z0-9\.\-\_]+?){1}/i", ' ', $_GET['nom']);
 
        echo "<div style='font-size:16px;font-family:Arial'>";
        echo "Just a test function for photos button and country: <b>".$country."</b><br/>";
        echo "<a href='".site_url('demo/offices_management_with_actions')."'>Go back to example</a>";
        echo "</div>";
        die();        
    }
		
	public function detail_four()
    {
    //    $crud = new grocery_CRUD();
		//$record_id = $_POST['record_id']; //set the record ID
  //  $crud->set_table('fournisseurs');
 
	// $crud->add_action('Smileys', 'http://www.grocerycrud.com/assets/uploads/general/smiley.png', '');

    //    $output = $crud->render();
   echo "<a href='".site_url('www.google.fr')."'>Go back to example</a>";
      //  $this->_example_output2($output);	
    }
	
	 
    function _example_output2($output = NULL)
 
    {
        $this->load->view('crude_exemple_vew',$output);    
    } 
	
	
	//////////////////////////////   
	
	  
    }    

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */